﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PreeRegisterModel;
using PreeRegisterDAL;
using System.Data;

namespace PreeRegisterBLL
{
    public class DepositPayBLL
    {
        /// <summary>
        /// 交住院押金
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static DepositPayResponseModel DepositPay(DepositPayRequestModel depositPayRequestModel)
        {
            try
            {
                DepositPayResponseModel depositPayResponseModel = new PreeRegisterModel.DepositPayResponseModel();

                //获取单据号
                string ReturnDepositReceipNo = DepositPayDAL.Up_ReturnDepositReceipNo();

                if (ReturnDepositReceipNo == "")
                {
                    depositPayResponseModel.code = "0";
                    depositPayResponseModel.msg = "交押金失败：获取单据号失败！";
                    return depositPayResponseModel;
                }

                //交住院押金
                DataSet ds = DepositPayDAL.DepositPay(depositPayRequestModel, ReturnDepositReceipNo);

                if (ds == null)
                {
                    depositPayResponseModel.code = "0";
                    depositPayResponseModel.msg = "交押金失败！";
                    return depositPayResponseModel;
                }

                depositPayResponseModel.code = ds.Tables[1].Rows[0]["code"].ToString();
                depositPayResponseModel.msg = ds.Tables[1].Rows[0]["msg"].ToString();
                depositPayResponseModel.cflowcode = ReturnDepositReceipNo;

                //返回
                return depositPayResponseModel;
            }
            catch (Exception err)
            {

                throw;
            }
        }
    }
}
